package jmine.tec.web.servlet.filter.transaction;

import static org.springframework.transaction.TransactionDefinition.ISOLATION_DEFAULT;
import static org.springframework.transaction.TransactionDefinition.PROPAGATION_REQUIRED;

import java.util.Collections;

import javax.servlet.ServletRequest;

import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.interceptor.RuleBasedTransactionAttribute;

/**
 * Factory padrão de TransactionAttribute
 * 
 * @author lundberg
 */
public class DefaultTransactionAttributeFactory implements TransactionDefinitionFactory {

    /**
     * {@inheritDoc}
     */
    public TransactionDefinition create(ServletRequest request) {
        final RuleBasedTransactionAttribute ta = new RuleBasedTransactionAttribute(PROPAGATION_REQUIRED, Collections.emptyList());
        ta.setIsolationLevel(ISOLATION_DEFAULT);
        ta.setName("defaultTransactionAttribute");
        return ta;
    }
}
